import json

import requests


def find(i):
    url = 'https://www.1905.com/api/content/index.php'
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36',
        'Cookie': '__uv_=6653203112; SpMLdaPxuv=m6333716428; Hm_up_49411f7bde52035653f2e2b70a0bb6a5=%7B%22uid_%22%3A%7B%22value%22%3A%226653203112%22%2C%22scope%22%3A1%7D%7D; WOlTvIlgRpuvid_=0817; Hm_lvt_5a9573957327e40b58294447cd1d8ad2=1598604413,1598833034; Hm_up_5a9573957327e40b58294447cd1d8ad2=%7B%22uid_%22%3A%7B%22value%22%3A%226653203112%22%2C%22scope%22%3A1%7D%7D; Hm_lvt_49411f7bde52035653f2e2b70a0bb6a5=1598604413,1598833035; PHPSESSID=g4j6atguc834c6a3nhsnb06e92; pvid=1598833902113; WOlTvIlgRptime_=1598833902113; Hm_lpvt_49411f7bde52035653f2e2b70a0bb6a5=1598833902; Hm_lpvt_5a9573957327e40b58294447cd1d8ad2=1598833903'
    }
    params = {
        'callback': 'reloadList',
        'm': 'converged',
        'a': 'info',
        'type': 'jryp',
        'year': '2019',
        'month': i
    }
    response = requests.get(url, headers=header, params=params)
    result = response.text
    # 去掉多余的元素
    result = result.replace('reloadList(', '').replace(')', '')
    # 将json格式数据转换为字典
    result = json.loads(result)
    # print(result['info'])
    # 每期时间
    print(result['info'][0]["airtime"])
    for i in result['info']:
        print(i["url"], i['title'], i['thumb'])


def main():
    # 1-12月份的数据
    for i in range(12):
        find(i+1)


if __name__ == '__main__':
    main()
